#include "Font.h"

#include <gl/gl.h>
#include <stdio.h>

#include "Window.h"

Font *Courier;

Font::Font(char *font, int size)
{
    base = glGenLists(96);
    HFONT hfont;

    hfont = CreateFont(size, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET,
                       OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
                       FF_DONTCARE | DEFAULT_PITCH, font);

    SelectObject(g_HDC, hfont);
    wglUseFontBitmaps(g_HDC, 32, 96, base);
    //ctor
}

Font::~Font()
{
    //dtor
}

void Font::Draw(char *str,int x,int y)
{
    /*glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glPushMatrix();

        glOrtho(0,WindowRect.width,WindowRect.height,0,0.0f,1.0f);

    glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glPushMatrix();*/
        glRasterPos2i(x, y);
        glPushAttrib(GL_LIST_BIT);
            glListBase(base - 32);
            glCallLists(strlen(str),GL_UNSIGNED_BYTE, str);
        glPopAttrib();

    /*glMatrixMode(GL_PROJECTION);
        glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
        glPopMatrix();*/
}

void StartupFontEngine()
{
    Courier = new Font("Courier",8);
}
